package com.star;

import com.star.dao.impl.BookDaoImpl;
import com.star.service.BookService;
import com.star.service.impl.BookServiceImpl;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class Main {
    public static void main(String[] args) {

        // 获取IOC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        BookService bookService = (BookService) ctx.getBean("bookService");
        BookService bookService1 = (BookService) ctx.getBean("bookService");
        System.out.println(bookService1.equals(bookService));
        System.out.println(bookService);
        System.out.println(bookService1);
        bookService.save();

        /*BookService bookService = new BookServiceImpl();
        bookService.save();*/

      /*  BookService bookService = new BookServiceImpl();
        ((BookServiceImpl) bookService).setBookDao(new BookDaoImpl());
        bookService.save();
*/
    }
}